<?php
class  CFile
{
    private $file;
     public function __construct()
     {
        ///$this->file = $filename;    
     }
     
  /** Upload file form <input type='file' .....>
   *  
   * @param string $filename  
   * @param string $destination      
   * @return bool True if successful, false on error. 
   * 
   * */       
public function upload($filename,$destination ,$allowed_extensions = array())
{
	$extension = pathinfo($_FILES[$filename]['name'], PATHINFO_EXTENSION);
    if(!in_array(strtolower($extension), $allowed_extensions) && !empty($allowed_extensions)){
        return false;
        exit;
    }
	if($_FILES[$filename]){
		if ($_FILES[$filename]["error"] > 0){
			echo "Return Code: " . $_FILES[$filename]["error"] . "<br />" ;
		} else {
		   /**
		   * echo "Upload: " . $_FILES[$filename]["name"] . "<br />";
		   *        echo "Type: " . $_FILES[$filename]["type"] . "<br />";
		   *        echo "Size: " . ($_FILES[$filename]["size"] / 1024) . " Kb<br />";
		   *        echo "Stored in: " . $_FILES[$filename]["tmp_name"];
		   */
			if(move_uploaded_file($_FILES[$filename]['tmp_name'], $destination)){
			   return true;
			}
			else
			   return false;
		}
	} else 
		echo "Error: FILE DONOT SET !";   
}


////////////////////////////////
}	
?>